<?php

namespace getMembers;

class GetMembers{
	
	private $con;
	
	public function __construct(){
			
		$this->con = mysqli_connect("localhost", "root", "", "benny");
	
		// Check connection
		if (mysqli_connect_errno())
		{
		echo "Failed to connect to MySQL: " . mysqli_connect_error();
		}	
	}
	
	public function addUser($user, $password){
		
			mysqli_query($this->con,"INSERT INTO users (Username, Password)
			VALUES ('$user', '$password')");
			mysqli_close($this->con);
			echo"succeded to add user";	
	}
	
	public function checkMember($username, $password){

		$result = mysqli_query($this->con,"SELECT * FROM users");

		while($row = mysqli_fetch_array($result)){
			if($username == $row['Username'] && $password == $row['Password']){
				return TRUE;
			}
  		}
		return FALSE;
	}
}
